package com.nuc.thread.status;

import lombok.extern.slf4j.Slf4j;

/**
 * @Description
 * @Author 诗酒趁年华
 * @Version V1.0.0
 * @Date 2021/5/5
 */
@Slf4j
public class InterruptTest2 {
    public static void main(String[] args) {
        Thread thread = new Thread(()->{
            while(true){
                log.debug("running");
                boolean interrupted = Thread.currentThread().isInterrupted();
                if (interrupted){
                    log.debug("被打断了");
                    break;
                }
            }

        });
        log.debug("interrupt");
        thread.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        thread.interrupt();
        log.debug("打断标识{}",thread.isInterrupted());
    }
}
